<template>
<view>
	<!-- <view class="act-navlist">
		<view v-for="(item,index) in navlist" :key="index" @click="navclick(item.id)">
			<view class="navlist-box">{{item.name}}</view>
		</view>
	</view> -->
	<v-tabs v-model="currentNewsIndex"
	 :tabs="navlist"
	 activeColor="#000"
	 lineColor="#24cba9"
	 lineHeight="5rpx"
	 :lineScale="1"
	 fontSize="34rpx"
	  @change="navclick"
	  ></v-tabs>
<view class="nodata_txt" v-if="actList.length===0">暂无相关数据~</view>
<view v-for="(item, idx) in actList" :key="idx" @tap="toDetail" class="act_sec" :data-recruit-id="item.id">
    <view class="img_sec">
        <image class="headimg" mode="scaleToFill" :src="item.thumb"></image>
        <image class="thumb" mode="scaletoFill" :src="item.thumb"></image>
    </view>
    <view class="title">{{item.title}}</view>
    <view class="desc flex">
        <view class="txt">报名时间：{{item.startTime}}</view>
        <view class="status" v-if="item.is_finish==1">已结束</view>
        <view @tap="toCancelSign" class="status checking" :data-recruit-id="item.id" v-if="item.is_finish!=1&&item.check_status==1">取消报名</view>
        <view class="status" v-if="item.is_finish!=1&&item.check_status==0">待审核</view>
        <view class="status" v-if="item.is_finish!=1&&item.check_status==2">未通过</view>
    </view>
</view>
</view>
</template>

<script>
var t = require("../../../utils/request.js"),
    e = function (t) {
  return t && t.__esModule ? t : {
    default: t
  };
}(require("../../../utils/api.js")),
    utils = require("../../../utils/util.js"),
		config = require("../../../utils/config.js").config,
    app = getApp(),
    recruitMyList = e.default.recruitMyList,
    o = e.default.cancelSignUp;

export default {
  data() {
    return {
	  currentNewsIndex: 0,
      page: 1,
      noMore: !1,
      actList: [],
	  // navlist:[
		 //  {name:'全部',id:''},
		 //  {name:'已结束',id:999},
		 //  {name:'取消报名',id:1},
		 //  {name:'待审核',id:0},
		 //  {name:'未通过',id:2},
	  // ],
	  navlist:['全部','待审核','已审核','被驳回'],
	  type:''
    };
  },

  components: {},
  props: {},
  onLoad: function (t) {
	  if(!app.globalData.zyzId){
		  uni.navigateTo({
		  	url:"/pages/entry/login"
		  })
	  }
    this.getMyActList(this.type);
  },
  onReady: function () {},
  onShow: function () {},
  onHide: function () {},
  onUnload: function () {},
  onPullDownRefresh: function () {
    this.setData({
      page: 1,
      noMore: !1
    }), this.getMyActList("refresh");
  },
  onReachBottom: function () {
    if (!this.noMore) {
      var t = this.page;
      this.setData({
        page: ++t
      }), this.getMyActList(this.type);
    }
  },
  onShareAppMessage: function () {
    return {
      title: "让公益更生活 让生活更公益",
      path: "/pages/index/index",
      imageUrl: "/static/images/zyh_logo.jpg"
    };
  },
  methods: {
	  navclick(index){
		  if(index==0){ // this.actLists=this.actList
			    this.type=''
		  }else if(index==2){
			  this.type=1
		  }else if(index==1){
			  this.type=0
		  }
		  else if(index==3){
			this.type=2
		  }
		  this.getMyActList()
		 
	  },
    getMyActList: function () {
		 this.actList=[]
      var e = this,
          o = arguments.length > 0 && void 0 !== arguments[0] ? arguments[0] : "load",
          r = {
        data: {
          api: recruitMyList,
          uid: app.globalData.zyzId,
          pageNo: this.page,
          pageSize: 10,
		  status:this.type
        }
      };
      return (0, t.request)(r, "normal", !0).then(function (t) {
		 
        if (t.data.success) {
          t.data.data.rows.length < 10 && e.setData({
            noMore: !0
          });
          var n = [];
          t.data.data.rows.forEach(function (single) {
						var activity = single.activity;
						activity.recruit_start_time = new Date(activity.startTime).getTime();
						activity.recruit_finish_time = new Date(activity.endTime).getTime();
            activity.startTime = (0, utils.formatTimeTwo)(activity.recruit_start_time, "Y年M月D日");
						activity.thumb = utils.formatImgUrl(activity.imageUrl, config.host);
						n.push(activity);
					});
          var i = e.actList;
          "refresh" === o ? (e.setData({
            actList: n
          }), uni.stopPullDownRefresh()) : e.setData({
            actList: i.concat(n)
          });
		  // e.actLists=e.actList
        }
      });
    },
    toCancelSign: function (t) {
      var e = this,
          n = t.currentTarget.dataset.recruitId;
      uni.showModal({
        title: "温馨提示",
        content: "确定取消报名此活动吗？",
        showCancle: !0,
        cancelText: "再看看",
        cancelColor: "#333333",
        confirmText: "立即取消",
        confirmColor: "#24CBA9",
        success: function (t) {
          t.confirm && e.cancelSignUp(n).then(function (t) {
            t.data.errCode === a.ERR_OK ? (e.setData({
              page: 1,
              noMore: !1
            }), e.getMyActList("refresh")) : uni.showToast({
              title: t.data.message,
              icon: "none"
            });
          });
        }
      });
    },
    cancelSignUp: function (e) {
      var a = {
        data: {
          api: o,
          id: e
        },
        token: app.globalData.token
      };
      return (0, t.request)(a, "common", !0);
    },
    toDetail: function (t) {
      uni.navigateTo({
        url: "/pages/act/detail?id=" + t.currentTarget.dataset.recruitId
      });
    }
  }
};
</script>
<style>
page {
    min-height: 100%;
    background: #f4f4f4;
    padding: 10rpx 0 75rpx;
}
.act-navlist{
	height: 90rpx;
}
.act-navlist .navlist-box{
	display: flex;
	/* width: 150rpx; */
	padding: 20rpx 20rpx;
	float: left;
}
.act-navlist .navlist-box:hover{
	color: #00B99E;
	border-bottom: 1rpx solid #00B99E;
}
.act_sec,page {
    width: 100%;
    height: auto;
}

.act_sec {
    min-height: 445rpx;
    padding: 30rpx;
    margin-bottom: 10rpx;
    background: #fff;
}

.img_sec {
    position: relative;
    width: 100%;
    height: 280rpx;
    margin-bottom: 30rpx;
}

.img_sec .tag {
    position: absolute;
    top: -8rpx;
    left: -8rpx;
    z-index: 3;
    width: 160rpx;
    height: 52rpx;
}

.img_sec .tag image {
    z-index: 4;
}

.img_sec .tag image,.img_sec .tag text {
    position: absolute;
    top: 0;
    left: 0;
    width: 100%;
    height: 100%;
}

.img_sec .tag text {
    z-index: 5;
    text-align: center;
    line-height: 48rpx;
    font-size: 24rpx;
    color: #fff;
}

.img_sec .thumb {
    width: 100%;
    height: 100%;
    border: 1rpx solid #e1e2e3;
    border-radius: 10rpx;
}

.img_sec .headimg {
    position: absolute;
    bottom: -40rpx;
    right: 30rpx;
    z-index: 5;
    width: 80rpx;
    height: 80rpx;
    border-radius: 50%;
}

.act_sec .title {
    width: 100%;
    margin-bottom: 20rpx;
    font-size: 32rpx;
    color: #333;
    white-space: nowrap;
    text-overflow: ellipsis;
    overflow: hidden;
}

.act_sec .desc {
    justify-content: space-between;
}

.act_sec .desc .txt {
    flex: 0 0 530rpx;
    width: 530rpx;
    font-size: 24rpx;
    color: #333;
}

.act_sec .desc .status {
    flex: 0 0 136rpx;
    width: 136rpx;
    height: 44rpx;
    line-height: 44rpx;
    text-align: center;
    background: #f2f2f2;
    font-size: 26rpx;
    color: #666;
}

.act_sec .desc .status.checking {
    background: #fff1e4;
    color: #f76500;
}

.act_sec .desc .status.refused {
    background: #ffefef;
    color: #e60012;
}
</style>